'use strict';
// Copyright 2014 Blueant Inc. All Rights Reserved.

/**
 * @fileoverview VIP
 * @author sundbcn@gmail.com (sun debing)
 */

var dataApi = require('../libs/dataApi');
var _ = require('lodash');

/**
 * 根据商城id 和 vip等级 获取可购买次数
 * @param  {[type]} vip [description]
 * @return {[type]}     [description]
 */
exports.getVipBuyShopNum = function (shop_id, vip) {
    var vip_shop_conf = dataApi.vip_shop.findById(shop_id);
    var long_num = _.size(vip_shop_conf);
    for (var i = 0; i < long_num; i++) {
        if (vip_shop_conf[i].vip_lvl == vip + 1) {
            return vip_shop_conf[i].buy_times;
        }
    }
    return 0;
};

/**
 * vip特权商店  根据ID---对应礼包奖励
 * @param  {[type]} vip [description]
 * @return {[type]}     [description]
 */
exports.getVipPrivilegeShopConf = function (shop_id) {
    var vip_shop_conf = dataApi.vip_privilege_shop.findById(shop_id);
    return vip_shop_conf;
};
